<?php

namespace app\admin\model\wu;

use think\Model;

class Procedurestatelog extends Model
{
    // 表名
    protected $name = 'wu_procedurestatelog';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = false;

    // 定义时间戳字段名
    protected $createTime = false;
    protected $updateTime = false;
    
    // 追加属性
    protected $append = [
        'state_text',
        'type_text'
    ];
    

    
    public function getStateList()
    {
        return ['0' => __('State 0'),'1' => __('State 1')];
    }     

    public function getTypeList()
    {
        return ['0' => __('Type 0'),'1' => __('Type 1'),'2' => __('Type 2'),'3' => __('Type 3')];
    }

    public function getProcedureTypeList()
    {
        return [
            '到廠' => '到廠', '刀柄雷標' => __('刀柄雷標'), '段差' => __('段差'), '半成品庫存' => __('半成品庫存'),
            '開刃' => '開刃', '白刀庫存' => __('白刀庫存'), '送鍍' => __('送鍍'), '檢驗' => __('檢驗'),
            '包裝貼標' => '包裝貼標', '回公司入庫' => __('回公司入庫')
        ];
    }


    public function getStateTextAttr($value, $data)
    {        
        $value = $value ? $value : (isset($data['state']) ? $data['state'] : '');
        $list = $this->getStateList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getTypeTextAttr($value, $data)
    {        
        $value = $value ? $value : (isset($data['type']) ? $data['type'] : '');
        $list = $this->getTypeList();
        return isset($list[$value]) ? $list[$value] : '';
    }




    public function jt()
    {
        return $this->belongsTo('Jt', 'jt_id', 'id', [], 'LEFT')->setEagerlyType(0);
    }


    public function productspec()
    {
        return $this->belongsTo('Productspec', 'productspec_id', 'id', [], 'LEFT')->setEagerlyType(0);
    }


    public function workorder()
    {
        return $this->belongsTo('Workorder', 'workorder_id', 'id', [], 'LEFT')->setEagerlyType(0);
    }


    public function procedure()
    {
        return $this->belongsTo('Procedure', 'procedure_id', 'id', [], 'LEFT')->setEagerlyType(0);
    }


    public function procedurestate()
    {
        return $this->belongsTo('Procedurestate', 'procedurestate_id', 'id', [], 'LEFT')->setEagerlyType(0);
    }


    public function man()
    {
        return $this->belongsTo('Man', 'man_id', 'id', [], 'LEFT')->setEagerlyType(0);
    }
}
